package cate.game.play.skill.passive.talent;

import cate.game.play.config.PlayCfgArgs;
import cate.game.play.proce.action.ctx.ActionCtx;
import cate.game.play.skill.passive.common.立即复活PH;

/**
 * 死亡时有60%概率复活，恢复最大生命值的10%,复活后提升10%攻击，持续2回合,每场最多触发3次
 */
public class 再生PH extends 立即复活PH {

	private int 概率;

	private double 恢复系数;

	private int buff;

	private int 最大次数;

	//概率=6000&恢复系数=1000&buff=？？&最大次数=3
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		概率 = args.getInt("概率", 0);
		恢复系数 = args.getWDouble("恢复系数",0d);
		buff = args.getInt("buff", 0);
		最大次数 = args.getInt("最大次数",0);
	}

	@Override
	public void parseExt(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		概率 += args.getInt("概率", 0);
	}

	@Override
	protected int getChance() {
		return 概率;
	}

	@Override
	protected int getResurrectMax() {return 最大次数;}

	@Override
	protected double healValue() {
		return skill.owner.attr.total().hpTotal()* 恢复系数;
	}

	@Override
	protected void onSuccess(ActionCtx action) {
		if (buff > 0) {
			skill.owner.buff.tryAddByTid(action, buff);
		}
	}
}
